package com.qhyt.generate;

import cn.afterturn.easypoi.excel.annotation.Excel;
import org.apache.commons.lang3.StringUtils;

/**
 * @author jie
 * @date 2020/11/12 -15:39
 */
public class Parameters {

    @Excel(name = "key", height = 20, width = 30)
    private String key;
    @Excel(name = "type", height = 20, width = 30)
    private String type;

    private String javaType;

    public String getJavaType() {
        if (StringUtils.isNotEmpty(getType())) {
            String lowerType = getType().toLowerCase();
            if ("date".equals(lowerType) || "datetime".equals(lowerType)) {
                return "Date";
            }
            if ("double".equals(lowerType) || "number".equals(lowerType) || "bigDecimal".equals(lowerType)) {
                return "BigDecimal";
            }
            if ("titlevalue".equals(lowerType) || "tv".equals(lowerType)) {
                return "TitleValueVo";
            }
            if ("list".equals(lowerType)) {
                return "List<String>";
            }
            if ("int".equals(lowerType) || "Integer".equals(lowerType)) {
                return "Integer";
            }
            if ("listobj".equals(lowerType)) {
                return "List<" + GenerateUtils.prefixLetterCap(key) + ">";
            }
        }

        return "String";
    }


    public void setJavaType(String javaType) {
        this.javaType = javaType;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return "Parameters{" +
                "key='" + key + '\'' +
                ", type='" + type + '\'' +
                ", javaType='" + javaType + '\'' +
                '}';
    }
}
